package wangjg.security.http;

import wangjg.security.core.ResourceMatcher;
import wangjg.security.util.matcher.Wildcard;

public class HttpResourceMatcher implements ResourceMatcher {

	@Override
	public boolean match(Object resource, Object request){
		if(resource instanceof HttpResource && request instanceof HttpRequest){
			HttpRequest httpRequest = (HttpRequest)request;
			HttpResource res = (HttpResource)resource;
			String pattern = res.getPattern();
			String path = httpRequest.getPath();
			return Wildcard.matches(pattern, path);	
		}
		return false;
	}
	
}
